Ext.onReady(function(){ 

Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'under';

var record_start = 0; 

var sm = new Ext.grid.CheckboxSelectionModel();
var cm=new Ext.grid.ColumnModel([ 
sm,
new Ext.grid.RowNumberer({header: "编号",
width:40, 
renderer:function(value,metadata,record,rowIndex){ 
return record_start + 1 + rowIndex; 
} 
}),
{header:'客户代码',dataIndex:'custId',hidden:true},
{header:'客户名称',dataIndex:'custName',width:100},
{header:'行业类型',dataIndex:'industryType',width:100,hidden:true}, 
{header:'违约状态',dataIndex:'defaultSta',width:100,hidden:true},
{header:'风险暴露分类',dataIndex:'exposureType',width:100,hidden:true},
{header:'信用评级',dataIndex:'phaseLevel',width:100},
{header:'信用评级生成日期',dataIndex:'phaseDate',width:100,hidden:true},
{header:'评级到期日',dataIndex:'endDate',width:100},
{header:'初评人',dataIndex:'firstUserId',width:100},
{header:'评级状态',dataIndex:'phaseStat',width:100,hidden:true}
]); 

var ds = new Ext.data.Store({ 
proxy:new Ext.data.HttpProxy({
url:'rating/listSortedPDFocusCustomer.do',
method:'POST'
}), 
reader:new Ext.data.JsonReader({ 
totalProperty:'total',  
root:'resultData'},[
{name:'custId', mapping: 'custInfo.custId'}, 
{name:'custName', mapping: 'custInfo.custName'},  
{name:'industryType', mapping: 'custInfo.industryType'},
{name:'defaultSta', mapping: 'custInfo.defaultSta'},
{name:'exposureType', mapping: 'custInfo.exposureType'},
{name:'phaseLevel', mapping: 'custPD.phaseLevel'},
{name:'phaseDate', mapping:' custPD.phaseDate'},
{name:'endDate',mapping:' custPD.endDate'},
{name:'firstUserId', mapping: 'custPD.firstUserId'},
{name:'phaseStat', mapping: 'custPD.phaseStat'}
]) 
}); 
ds.load({params:{start:0,limit:5}}); 

var grid=new Ext.grid.GridPanel({ 
id:'myCustomers',
renderTo:"focus_customer", 
stripeRows:true,//斑马线效果
title:"我的关注列表", 
height:230, 
cm:cm,
store: ds, 
loadMask: { msg: "加载中..." }, 
viewConfig: {   
                            forceFit:true   
            },   
	bbar: new Ext.PagingToolbar({   
	    pageSize: 5,   
	    store: ds,
	    displayInfo: true,     
	    emptyMsg: "没有数据" ,
	    doLoad : function(start){ 
				 	record_start = start; 
					var o = {}, pn = this.getParams(); 
				    o[pn.start] = start; 
				    o[pn.limit] = this.pageSize; 
					this.store.load({params:o}); 
		}   
	}),
 tbar: [{text:'查看客户评级详情',icon:'images/arrow.gif', handler: listCustPD},'-',]              
});

function listCustPD(){
	if (grid.getSelectionModel().getSelections()[0] == undefined) { 
		Ext.Msg.alert("提示", "请选中要操作的项！"); 
	}
	else{
		var selectedCustId = grid.getSelectionModel().getSelections()[0].data.custId;
		window.location.href="rating/showHistoryPDList.do?CustId="+selectedCustId;
	}
}

function rowdblclickFn(grid, rowIndex, e){//双击事件  
	var row = grid.getStore().getAt(rowIndex); 
	var selectedCustId = row.get("custId");
	window.location.href="rating/showHistoryPDList.do?CustId="+selectedCustId;  
}   

grid.addListener('rowdblclick',rowdblclickFn);

}); 